
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>c · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-versions-select/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="c基础.html" />
    
    
    <link rel="prev" href="../linux/android底层开发.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../linux/linux基础.html">
            
                <a href="../linux/linux基础.html">
            
                    
                    linux基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../linux/android底层开发.html">
            
                <a href="../linux/android底层开发.html">
            
                    
                    android底层开发
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter active" data-level="1.3" data-path="c基础.html">
            
                <a href="c基础.html">
            
                    
                    c
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.3.1" data-path="c基础.html">
            
                <a href="c基础.html">
            
                    
                    c基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../c++/c++基础.html">
            
                <a href="../c++/c++基础.html">
            
                    
                    c++基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../QT/QT基础.html">
            
                <a href="../QT/QT基础.html">
            
                    
                    QT基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../jni/JNI基础.html">
            
                <a href="../jni/JNI基础.html">
            
                    
                    JNI基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../jni/JNI例子.html">
            
                <a href="../jni/JNI例子.html">
            
                    
                    JNI例子
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../SDL/SDL基础.html">
            
                <a href="../SDL/SDL基础.html">
            
                    
                    SDL基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../ffmpeg/ffmpeg基础.html">
            
                <a href="../ffmpeg/ffmpeg基础.html">
            
                    
                    ffmpeg基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../ffmpeg/ffmpeg示例代码.html">
            
                <a href="../ffmpeg/ffmpeg示例代码.html">
            
                    
                    ffmpeg示例代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                <a href="../ffmpeg/ffmpeg软解rtsp简单直播.html">
            
                    
                    ffmpeg软解rtsp简单直播
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../ffmpeg/rtsp服务器.html">
            
                <a href="../ffmpeg/rtsp服务器.html">
            
                    
                    rtsp服务器Windows
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../opencv/opencv模块.html">
            
                <a href="../opencv/opencv模块.html">
            
                    
                    opencv模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../opencv/opencv.html">
            
                <a href="../opencv/opencv.html">
            
                    
                    opencv
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../openSLES/openSLES基础.html">
            
                <a href="../openSLES/openSLES基础.html">
            
                    
                    openSLES基础
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    SoundTouch
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../SoundTouch/移植SoundTouch.html">
            
                <a href="../SoundTouch/移植SoundTouch.html">
            
                    
                    移植SoundTouch
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../SoundTouch/实现音频变速和变调.html">
            
                <a href="../SoundTouch/实现音频变速和变调.html">
            
                    
                    实现音频变速和变调
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../openGLES/openGLES基础.html">
            
                <a href="../openGLES/openGLES基础.html">
            
                    
                    openGLES模块
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../openGLES/GLSL基础.html">
            
                <a href="../openGLES/GLSL基础.html">
            
                    
                    GLSL基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../openGLES/openglES示例.html">
            
                <a href="../openGLES/openglES示例.html">
            
                    
                    openglES示例
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频术语-文件格式-协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../视频相关/音视频基础.html">
            
                <a href="../视频相关/音视频基础.html">
            
                    
                    音视频基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../视频相关/RTSP.html">
            
                <a href="../视频相关/RTSP.html">
            
                    
                    RTSP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../视频相关/RTP.html">
            
                <a href="../视频相关/RTP.html">
            
                    
                    RTP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../视频相关/RTCP.html">
            
                <a href="../视频相关/RTCP.html">
            
                    
                    RTCP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.5" data-path="../视频相关/H264.html">
            
                <a href="../视频相关/H264.html">
            
                    
                    H264
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.6" data-path="../视频相关/YUV.html">
            
                <a href="../视频相关/YUV.html">
            
                    
                    YUV
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.7" data-path="../视频相关/SurfaceView.html">
            
                <a href="../视频相关/SurfaceView.html">
            
                    
                    SurfaceView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.8" data-path="../视频相关/RTMP.html">
            
                <a href="../视频相关/RTMP.html">
            
                    
                    RTMP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.9" data-path="../视频相关/AAC详解.html">
            
                <a href="../视频相关/AAC详解.html">
            
                    
                    AAC详解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../音视频相关代码/音视频相关代码.html">
            
                <a href="../音视频相关代码/音视频相关代码.html">
            
                    
                    音视频相关代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK工程编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../ndk/NDK编译基础.html">
            
                <a href="../ndk/NDK编译基础.html">
            
                    
                    NDK编译基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../ndk/cmake方式.html">
            
                <a href="../ndk/cmake方式.html">
            
                    
                    cmake
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../ndk/Android.mk模板.html">
            
                <a href="../ndk/Android.mk模板.html">
            
                    
                    Android.mk
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.4" data-path="../ndk/Application.mk模板.html">
            
                <a href="../ndk/Application.mk模板.html">
            
                    
                    Application.mk
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >c</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#c&#x8BED;&#x8A00;&#x57FA;&#x7840;"><b>1. </b>c&#x8BED;&#x8A00;&#x57FA;&#x7840;</a></li><ul><li><span class="title-icon "></span><a href="#&#x6570;&#x636E;&#x7C7B;&#x578B;"><b>1.1. </b>&#x6570;&#x636E;&#x7C7B;&#x578B;</a></li><li><span class="title-icon "></span><a href="#printf-&#x8F93;&#x51FA;&#x683C;&#x5F0F;-&#x3001;&#x5360;&#x4F4D;&#x7B26;"><b>1.2. </b>printf &#x8F93;&#x51FA;&#x683C;&#x5F0F; &#x3001;&#x5360;&#x4F4D;&#x7B26;</a></li><li><span class="title-icon "></span><a href="#&#x5B57;&#x7B26;&#x4E32;"><b>1.3. </b>&#x5B57;&#x7B26;&#x4E32;</a></li><li><span class="title-icon "></span><a href="#&#x6307;&#x9488;"><b>1.4. </b>&#x6307;&#x9488;</a></li><ul><li><span class="title-icon "></span><a href="#&#x4E8C;&#x7EA7;&#x6307;&#x9488;-&#x3001;&#x591A;&#x7EA7;&#x6307;&#x9488;"><b>1.4.1. </b>&#x4E8C;&#x7EA7;&#x6307;&#x9488; &#x3001;&#x591A;&#x7EA7;&#x6307;&#x9488;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;&#x6307;&#x9488;"><b>1.4.2. </b>&#x6570;&#x7EC4;&#x6307;&#x9488;</a></li><li><span class="title-icon "></span><a href="#&#x51FD;&#x6570;&#x6307;&#x9488;-&#x3001;-&#x65B9;&#x6CD5;&#x6307;&#x9488;"><b>1.4.3. </b>&#x51FD;&#x6570;&#x6307;&#x9488; &#x3001; &#x65B9;&#x6CD5;&#x6307;&#x9488;</a></li></ul><li><span class="title-icon "></span><a href="#&#x51FD;&#x6570;&#x56DE;&#x8C03;"><b>1.5. </b>&#x51FD;&#x6570;&#x56DE;&#x8C03;</a></li><li><span class="title-icon "></span><a href="#&#x6570;&#x7EC4;"><b>1.6. </b>&#x6570;&#x7EC4;</a></li><li><span class="title-icon "></span><a href="#&#x53D8;&#x91CF;"><b>1.7. </b>&#x53D8;&#x91CF;</a></li><li><span class="title-icon "></span><a href="#&#x5806;&#x6808;-&#x3001;&#x5185;&#x5B58;"><b>1.8. </b>&#x5806;&#x6808; &#x3001;&#x5185;&#x5B58;</a></li><ul><li><span class="title-icon "></span><a href="#&#x9759;&#x6001;&#x5185;&#x5B58;"><b>1.8.1. </b>&#x9759;&#x6001;&#x5185;&#x5B58;</a></li><li><span class="title-icon "></span><a href="#&#x52A8;&#x6001;&#x5185;&#x5B58;"><b>1.8.2. </b>&#x52A8;&#x6001;&#x5185;&#x5B58;</a></li><li><span class="title-icon "></span><a href="#&#x5185;&#x5B58;&#x56DB;&#x533A;&#x6A21;&#x578B;"><b>1.8.3. </b>&#x5185;&#x5B58;&#x56DB;&#x533A;&#x6A21;&#x578B;</a></li></ul><li><span class="title-icon "></span><a href="#&#x7ED3;&#x6784;&#x4F53;"><b>1.9. </b>&#x7ED3;&#x6784;&#x4F53;</a></li><li><span class="title-icon "></span><a href="#&#x8054;&#x5408;&#x4F53;-&#x5171;&#x7528;&#x4F53;"><b>1.10. </b>&#x8054;&#x5408;&#x4F53; &#x5171;&#x7528;&#x4F53;</a></li><li><span class="title-icon "></span><a href="#&#x63A7;&#x5236;&#x53F0;-&#x8F93;&#x5165;-&#x8F93;&#x51FA;"><b>1.11. </b>&#x63A7;&#x5236;&#x53F0; &#x8F93;&#x5165; &#x8F93;&#x51FA;</a></li><li><span class="title-icon "></span><a href="#&#x5E38;&#x7528;&#x51FD;&#x6570;"><b>1.12. </b>&#x5E38;&#x7528;&#x51FD;&#x6570;</a></li><ul><li><span class="title-icon "></span><a href="#memcpy"><b>1.12.1. </b>memcpy(...)</a></li><li><span class="title-icon "></span><a href="#memset"><b>1.12.2. </b>memset(...)</a></li></ul><li><span class="title-icon "></span><a href="#&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><b>1.13. </b>&#x6587;&#x4EF6;&#x64CD;&#x4F5C;</a></li><ul><li><span class="title-icon "></span><a href="#&#x8BFB;&#x5199;&#x6743;&#x9650;"><b>1.13.1. </b>&#x8BFB;&#x5199;&#x6743;&#x9650;</a></li><li><span class="title-icon "></span><a href="#&#x8BFB;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;"><b>1.13.2. </b>&#x8BFB;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;</a></li><li><span class="title-icon "></span><a href="#&#x5199;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;"><b>1.13.3. </b>&#x5199;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;</a></li><li><span class="title-icon "></span><a href="#&#x590D;&#x5236;&#x6587;&#x4EF6;-&#xFF0C;&#x4E8C;&#x8FDB;&#x5236;&#xFF08;&#x56FE;&#x7247;&#xFF0C;&#x97F3;&#x9891;&#xFF09;"><b>1.13.4. </b>&#x590D;&#x5236;&#x6587;&#x4EF6; &#xFF0C;&#x4E8C;&#x8FDB;&#x5236;&#xFF08;&#x56FE;&#x7247;&#xFF0C;&#x97F3;&#x9891;&#xFF09;</a></li></ul></ul></ul></div><a href="#c&#x8BED;&#x8A00;&#x57FA;&#x7840;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="c&#x8BED;&#x8A00;&#x57FA;&#x7840;"><a name="c&#x8BED;&#x8A00;&#x57FA;&#x7840;" class="anchor-navigation-ex-anchor" href="#c&#x8BED;&#x8A00;&#x57FA;&#x7840;"><i class="fa fa-link" aria-hidden="true"></i></a>1. c&#x8BED;&#x8A00;&#x57FA;&#x7840;</h1>
<h2 id="&#x6570;&#x636E;&#x7C7B;&#x578B;"><a name="&#x6570;&#x636E;&#x7C7B;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x636E;&#x7C7B;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<table>
<thead>
<tr>
<th>c&#x57FA;&#x7840;&#x6570;&#x636E;&#x7C7B;&#x578B;</th>
<th>&#x5B57;&#x8282;</th>
<th>&#x8BF4;&#x660E;</th>
</tr>
</thead>
<tbody>
<tr>
<td>char</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>unsigned char</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>signed char</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>int</td>
<td>2 &#x6216;4</td>
<td></td>
</tr>
<tr>
<td>unsigned int</td>
<td>2 &#x6216;4</td>
<td></td>
</tr>
<tr>
<td>short</td>
<td>2</td>
<td></td>
</tr>
<tr>
<td>unsigned short</td>
<td>2</td>
<td></td>
</tr>
<tr>
<td>long</td>
<td>4</td>
<td></td>
</tr>
<tr>
<td>unsigned long</td>
<td>4</td>
<td></td>
</tr>
<tr>
<td>float</td>
<td>4</td>
<td></td>
</tr>
<tr>
<td>double</td>
<td>8</td>
<td></td>
</tr>
<tr>
<td>long double</td>
<td>16</td>
<td></td>
</tr>
<tr>
<td>&#x6CA1;&#x6709; boolean</td>
<td></td>
<td>0&#x5047; , &#x975E;0&#x771F;</td>
</tr>
<tr>
<td>&#x6CA1;&#x6709; byte</td>
<td></td>
<td>unsigned char</td>
</tr>
</tbody>
</table>
<pre><code class="lang-c"><span class="hljs-keyword">signed</span> <span class="hljs-keyword">int</span> value;    <span class="hljs-comment">// &#x6709;&#x7B26;&#x53F7;&#x7C7B;&#x578B;</span>
<span class="hljs-keyword">int</span> value;          <span class="hljs-comment">// &#x4E0D;&#x5199;&#x5C31;&#x9ED8;&#x8BA4;&#x4E3A;&#x6709;&#x7B26;&#x53F7;&#x7C7B;&#x578B;</span>
<span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> value;<span class="hljs-comment">// &#x65E0;&#x7B26;&#x53F7;&#x7C7B;&#x578B;</span>
</code></pre>
<p><br></p>
<h2 id="printf-&#x8F93;&#x51FA;&#x683C;&#x5F0F;-&#x3001;&#x5360;&#x4F4D;&#x7B26;"><a name="printf-&#x8F93;&#x51FA;&#x683C;&#x5F0F;-&#x3001;&#x5360;&#x4F4D;&#x7B26;" class="anchor-navigation-ex-anchor" href="#printf-&#x8F93;&#x51FA;&#x683C;&#x5F0F;-&#x3001;&#x5360;&#x4F4D;&#x7B26;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. printf &#x8F93;&#x51FA;&#x683C;&#x5F0F; &#x3001;&#x5360;&#x4F4D;&#x7B26;</h2>
<table>
<thead>
<tr>
<th>&#x7C7B;&#x578B;type</th>
<th>&#x5BF9;&#x5E94;&#x7C7B;&#x578B;</th>
<th>&#x8BF4;&#x660E;</th>
<th>&#x793A;&#x4F8B;</th>
</tr>
</thead>
<tbody>
<tr>
<td>d/i</td>
<td>int</td>
<td>&#x8F93;&#x51FA;&#x5341;&#x8FDB;&#x5236;&#x6709;&#x7B26;&#x53F7;32bits&#x6574;&#x6570;&#xFF0C;i&#x662F;&#x8001;&#x5F0F;&#x5199;&#x6CD5;</td>
<td>printf(&quot;%i&quot;,123); <br>&#x8F93;&#x51FA;123</td>
</tr>
<tr>
<td>u</td>
<td>unsigned int</td>
<td>&#x65E0;&#x7B26;&#x53F7;10&#x8FDB;&#x5236;&#x6574;&#x6570;</td>
<td>printf(&quot;%u&quot;,123);<br> &#x8F93;&#x51FA;123</td>
</tr>
<tr>
<td>o</td>
<td>unsigned int</td>
<td>&#x65E0;&#x7B26;&#x53F7;8&#x8FDB;&#x5236;&#x6574;&#x6570;(&#x4E0D;&#x8F93;&#x51FA;&#x524D;&#x7F00;0)</td>
<td>printf(&quot;0%o&quot;,123);<br>&#x8F93;&#x51FA;0173</td>
</tr>
<tr>
<td>x/X</td>
<td>unsigned int</td>
<td>&#x65E0;&#x7B26;&#x53F7;16&#x8FDB;&#x5236;&#x6574;&#x6570;&#xFF0C;x&#x5BF9;&#x5E94;&#x7684;&#x5C0F;&#x5199;&#xFF0C;X&#x5BF9;&#x5E94;&#x7684;&#x662F;&#x5927;&#x5199;&#xFF08;&#x4E0D;&#x8F93;&#x51FA;&#x524D;&#x7F00;0x)</td>
<td>printf(&quot;0x%x 0x%X&quot;,123,123);<br>&#x8F93;&#x51FA;0x7b 0x7B</td>
</tr>
<tr>
<td>f/lf</td>
<td>float(double)</td>
<td>&#x5355;&#x7CBE;&#x5EA6;&#x6D6E;&#x70B9;&#x6570;&#x7528;f,&#x53CC;&#x7CBE;&#x5EA6;&#x6D6E;&#x70B9;&#x6570;&#x7528;lf(printf&#x53EF;&#x6DF7;&#x7528;&#xFF0C;&#x4F46;scanf&#x4E0D;&#x80FD;&#x6DF7;&#x7528;)</td>
<td>printf(&quot;%.9f %.9lf&quot;,0.000000123,0.000000123);<br>&#x8F93;&#x51FA;0.000000123 0.000000123&#x3002;<br>&#x6CE8;&#x610F;&#x6307;&#x5B9A;&#x7CBE;&#x5EA6;&#xFF0C;&#x5426;&#x5219;printf&#x9ED8;&#x8BA4;&#x7CBE;&#x786E;&#x5230;&#x5C0F;&#x6570;&#x70B9;&#x540E;&#x516D;&#x4F4D;</td>
</tr>
<tr>
<td>F</td>
<td>float(double)</td>
<td>&#x4E0E;f&#x683C;&#x5F0F;&#x76F8;&#x540C;&#xFF0C;&#x53EA;&#x4E0D;&#x8FC7; infinity &#x548C; nan &#x8F93;&#x51FA;&#x4E3A;&#x5927;&#x5199;&#x5F62;&#x5F0F;&#x3002;</td>
<td>printf(&quot;%f %F %f %F\n&quot;,INFINITY,INFINITY,NAN,NAN);<br>&#x8F93;&#x51FA;&#x7ED3;&#x679C;&#x4E3A;inf INF nan NAN</td>
</tr>
<tr>
<td>e/E</td>
<td>float(double)</td>
<td>&#x79D1;&#x5B66;&#x8BA1;&#x6570;&#x6CD5;&#xFF0C;<br>&#x4F7F;&#x7528;&#x6307;&#x6570;(Exponent)&#x8868;&#x793A;&#x6D6E;&#x70B9;&#x6570; <br>&#x6B64;&#x5904;&#x201D;e&#x201D;&#x7684;&#x5927;&#x5C0F;&#x5199;&#x4EE3;&#x8868;&#x5728;&#x8F93;&#x51FA;&#x65F6;&#x201C;e&#x201D;&#x7684;&#x5927;&#x5C0F;&#x5199;</td>
<td>printf(&quot;%e %E&quot;,0.000000123,0.000000123);<br>&#x8F93;&#x51FA;1.230000e-07 1.230000E-07</td>
</tr>
<tr>
<td>g</td>
<td>float(double)</td>
<td>&#x6839;&#x636E;&#x6570;&#x503C;&#x7684;&#x957F;&#x5EA6;&#xFF0C;&#x9009;&#x62E9;&#x4EE5;&#x6700;&#x77ED;&#x7684;&#x65B9;&#x5F0F;&#x8F93;&#x51FA;&#xFF0C;%f&#x6216;%e</td>
<td>printf(&quot;%g %g&quot;,0.000000123,0.123);<br>&#x8F93;&#x51FA;1.23e-07 0.123</td>
</tr>
<tr>
<td>G</td>
<td>float(double)</td>
<td>&#x6839;&#x636E;&#x6570;&#x503C;&#x7684;&#x957F;&#x5EA6;&#xFF0C;&#x9009;&#x62E9;&#x4EE5;&#x6700;&#x77ED;&#x7684;&#x65B9;&#x5F0F;&#x8F93;&#x51FA;&#xFF0C;%f&#x6216;%E</td>
<td>printf(&quot;%G %G&quot;,0.000000123,0.123);<br>&#x8F93;&#x51FA;1.23E-07 0.123</td>
</tr>
<tr>
<td>c</td>
<td>char</td>
<td>&#x5B57;&#x7B26;&#x578B;&#x3002;<br>&#x53EF;&#x4EE5;&#x628A;&#x8F93;&#x5165;&#x7684;&#x6570;&#x5B57;&#x6309;&#x7167;ASCII&#x7801;&#x76F8;&#x5E94;&#x8F6C;&#x6362;&#x4E3A;&#x5BF9;&#x5E94;&#x7684;&#x5B57;&#x7B26;</td>
<td>printf(&quot;%c\n&quot;,64)&#x8F93;&#x51FA;A</td>
</tr>
<tr>
<td>s</td>
<td>char*</td>
<td>&#x5B57;&#x7B26;&#x4E32;&#x3002;<br>&#x8F93;&#x51FA;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7684;&#x5B57;&#x7B26;&#x76F4;&#x81F3;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7684;&#x7A7A;&#x5B57;&#x7B26;&#xFF08;&#x5B57;&#x7B26;&#x4E32;&#x4EE5;&#x7A7A;&#x5B57;&#x7B26;&#x2019;\0&#x2018;&#x7ED3;&#x5C3E;&#xFF09;</td>
<td>printf(&quot;%s&quot;,&quot;&#x6D4B;&#x8BD5;test&quot;);<br>&#x8F93;&#x51FA;&#xFF1A;&#x6D4B;&#x8BD5;test</td>
</tr>
<tr>
<td>S</td>
<td>wchar_t*</td>
<td>&#x5BBD;&#x5B57;&#x7B26;&#x4E32;&#x3002;&#x8F93;&#x51FA;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7684;&#x5B57;&#x7B26;&#x76F4;&#x81F3;&#x5B57;&#x7B26;&#x4E32;&#x4E2D;&#x7684;&#x7A7A;&#x5B57;&#x7B26;&#xFF08;&#x5BBD;&#x5B57;&#x7B26;&#x4E32;&#x4EE5;&#x4E24;&#x4E2A;&#x7A7A;&#x5B57;&#x7B26;&#x2019;\0&#x2018;&#x7ED3;&#x5C3E;&#xFF09;</td>
<td>setlocale(LC_ALL,&quot;zh_CN.UTF-8&quot;); <br> wchar_t wtest[]=L&quot;&#x6D4B;&#x8BD5;Test&quot;;  <br>printf(&quot;%S\n&quot;,wtest);  <br>&#x8F93;&#x51FA;&#xFF1A;&#x6D4B;&#x8BD5;test</td>
</tr>
<tr>
<td>p</td>
<td>void*</td>
<td>&#x4EE5;16&#x8FDB;&#x5236;&#x5F62;&#x5F0F;&#x8F93;&#x51FA;&#x6307;&#x9488;</td>
<td>printf(&quot;%010p&quot;,&quot;lvlv&quot;);<br>&#x8F93;&#x51FA;&#xFF1A;0x004007e6</td>
</tr>
<tr>
<td>n</td>
<td>int*</td>
<td>&#x4EC0;&#x4E48;&#x4E5F;&#x4E0D;&#x8F93;&#x51FA;&#x3002;%n&#x5BF9;&#x5E94;&#x7684;&#x53C2;&#x6570;&#x662F;&#x4E00;&#x4E2A;&#x6307;&#x5411;signed int&#x7684;&#x6307;&#x9488;&#xFF0C;&#x5728;&#x6B64;&#x4E4B;&#x524D;&#x8F93;&#x51FA;&#x7684;&#x5B57;&#x7B26;&#x6570;&#x5C06;&#x5B58;&#x50A8;&#x5230;&#x6307;&#x9488;&#x6240;&#x6307;&#x7684;&#x4F4D;&#x7F6E;</td>
<td>int num=0; <br> printf(&quot;lvlv%n&quot;,&amp;num); <br> printf(&quot;num:%d&quot;,num); <br> &#x8F93;&#x51FA;:lvlvnum:4</td>
</tr>
<tr>
<td>%</td>
<td>&#x5B57;&#x7B26;%</td>
<td>&#x8F93;&#x51FA;&#x5B57;&#x7B26;&#x2018;%&#x2019;&#xFF08;&#x767E;&#x5206;&#x53F7;&#xFF09;&#x672C;&#x8EAB;</td>
<td>printf(&quot;%%&quot;);&#x8F93;&#x51FA;:%</td>
</tr>
<tr>
<td>m</td>
<td>&#x65E0;</td>
<td>&#x6253;&#x5370;errno&#x503C;&#x5BF9;&#x5E94;&#x7684;&#x51FA;&#x9519;&#x5185;&#x5BB9;</td>
<td>printf(&quot;%m\n&quot;);</td>
</tr>
<tr>
<td>a/A</td>
<td>float(double)</td>
<td>&#x5341;&#x516D;&#x8FDB;&#x5236;p&#x8BA1;&#x6570;&#x6CD5;&#x8F93;&#x51FA;&#x6D6E;&#x70B9;&#x6570;&#xFF0C;a&#x4E3A;&#x5C0F;&#x5199;&#xFF0C;A&#x4E3A;&#x5927;&#x5199;</td>
<td>printf(&quot;%a %A&quot;,15.15,15.15);<br>&#x8F93;&#x51FA;&#xFF1A;0x1.e4ccccccccccdp+3 0X1.E4CCCCCCCCCCDP+3</td>
</tr>
</tbody>
</table>
<pre><code class="lang-c"><span class="hljs-comment">//&#x51FD;&#x6570;&#x539F;&#x578B;</span>
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x683C;&#x5F0F;&#x5316;&#x5B57;&#x7B26;&#x4E32;&quot;</span>,&#x8F93;&#x51FA;&#x8868;&#x5217;)
<span class="hljs-comment">//&#x683C;&#x5F0F;&#x63A7;&#x5236;&#x5B57;&#x7B26;&#x4E32;</span>
%[flags][width][.prec][length]type
%[&#x6807;&#x5FD7;][&#x6700;&#x5C0F;&#x5BBD;&#x5EA6;][.&#x7CBE;&#x5EA6;][&#x7C7B;&#x578B;&#x957F;&#x5EA6;]&#x7C7B;&#x578B;

<span class="hljs-keyword">int</span> value = <span class="hljs-number">12345</span>;
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x53F3;&#x8FB9;&#x8865;&#x7A7A;&#x683C;=%-10d\n&quot;</span>, value);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x5DE6;&#x8FB9;&#x8865;&#x7A7A;&#x683C;=%10d\n&quot;</span>, value);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x5DE6;&#x8FB9;&#x8865;&#x96F6;= %010d\n&quot;</span>, value);

<span class="hljs-keyword">float</span> value2 = <span class="hljs-number">100.123456789</span>;
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x7CBE;&#x5EA6;= %.5f\n&quot;</span>, value2);
</code></pre>
<h2 id="&#x5B57;&#x7B26;&#x4E32;"><a name="&#x5B57;&#x7B26;&#x4E32;" class="anchor-navigation-ex-anchor" href="#&#x5B57;&#x7B26;&#x4E32;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x5B57;&#x7B26;&#x4E32;</h2>
<pre><code class="lang-c"><span class="hljs-comment">//  &apos;\0&apos; &#x7EC8;&#x6B62;&#x6807;&#x8BB0;</span>
<span class="hljs-keyword">char</span> greeting[<span class="hljs-number">6</span>] = { <span class="hljs-string">&apos;H&apos;</span>, <span class="hljs-string">&apos;e&apos;</span>, <span class="hljs-string">&apos;l&apos;</span>, <span class="hljs-string">&apos;l&apos;</span>, <span class="hljs-string">&apos;o&apos;</span>, <span class="hljs-string">&apos;\0&apos;</span> };
<span class="hljs-keyword">char</span> greeting[] = <span class="hljs-string">&quot;Hello&quot;</span>;

<span class="hljs-comment">//&#x590D;&#x5236; str1 &#x5230; str3</span>
<span class="hljs-built_in">strcpy</span>(str3, str1);
<span class="hljs-comment">//&#x8FDE;&#x63A5; str1 &#x548C; str2</span>
<span class="hljs-built_in">strcat</span>(str1, str2);
<span class="hljs-comment">//&#x5B57;&#x7B26;&#x4E32;&#x957F;&#x5EA6;</span>
len = <span class="hljs-built_in">strlen</span>(str1);

<span class="hljs-keyword">char</span> s1[] = <span class="hljs-string">&quot;aivin666@qq.com&quot;</span>;
<span class="hljs-keyword">char</span> ch = <span class="hljs-string">&apos;@&apos;</span>;
<span class="hljs-comment">// &#x8FD4;&#x56DE;&#x9996;&#x6B21;&#x51FA;&#x73B0;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x7684;&#x6307;&#x9488;&#x4F4D;&#x7F6E;</span>
<span class="hljs-keyword">char</span>* location=<span class="hljs-built_in">strchr</span>(s1, ch);
<span class="hljs-keyword">if</span> (location)
{
  <span class="hljs-comment">// qq.com</span>
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;%s\n&quot;</span>, ++location);
}
<span class="hljs-keyword">else</span> {
  <span class="hljs-comment">// &#x4E0D;&#x5B58;&#x5728;&#x5C31;&#x4F1A;&#x8FD4;&#x56DE;NULL</span>
}

<span class="hljs-keyword">char</span> s1[] = <span class="hljs-string">&quot;aivin666@qq.com&quot;</span>;
<span class="hljs-keyword">char</span> s2[] = <span class="hljs-string">&quot;666&quot;</span>;
<span class="hljs-comment">// &#x8FD4;&#x56DE;&#x9996;&#x6B21;&#x51FA;&#x73B0;&#x76EE;&#x6807;&#x5B57;&#x7B26;&#x4E32;&#x7684;&#x6307;&#x9488;&#x4F4D;&#x7F6E;</span>
<span class="hljs-keyword">char</span>* location= <span class="hljs-built_in">strstr</span>(s1, s2);
<span class="hljs-keyword">if</span> (location)
{
  <span class="hljs-comment">//666@qq.com</span>
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;%s\n&quot;</span>, location);
}
<span class="hljs-keyword">else</span> {
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x5339;&#x914D;&#x5931;&#x8D25;\n&quot;</span>);
}

<span class="hljs-comment">// &#x5B57;&#x7B26;&#x4E32;&#x6BD4;&#x8F83; ,&#x76F8;&#x7B49;&#x8868;&#x793A; &#x5B57;&#x7B26;&#x4E32;&#x5185;&#x5BB9;&#x76F8;&#x540C;</span>
<span class="hljs-function"><span class="hljs-keyword">int</span> <span class="hljs-title">memcmp</span><span class="hljs-params">(<span class="hljs-keyword">const</span> <span class="hljs-keyword">void</span> *buf1, <span class="hljs-keyword">const</span> <span class="hljs-keyword">void</span> *buf2, <span class="hljs-keyword">unsigned</span> <span class="hljs-keyword">int</span> count)</span></span>;
<span class="hljs-comment">//&#x5339;&#x914D;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x6210;&#x529F;&#x5219;&#x8FD4;&#x56DE;&#x7B2C;&#x4E00;&#x6B21;&#x5339;&#x914D;&#x5230;&#x7684;&#x5730;&#x5740;&#xFF0C;&#x5931;&#x8D25;&#x8FD4;&#x56DE;&#x7A7A;</span>
strcasestr(url, <span class="hljs-string">&quot;rtsp://&quot;</span>)
</code></pre>
<p><br></p>
<h2 id="&#x6307;&#x9488;"><a name="&#x6307;&#x9488;" class="anchor-navigation-ex-anchor" href="#&#x6307;&#x9488;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. &#x6307;&#x9488;</h2>
<p>&#x6307;&#x9488;&#x662F;&#x4E00;&#x4E2A;&#x53D8;&#x91CF;&#xFF0C;&#x5B58;&#x50A8;&#x4E86;&#x67D0;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x5185;&#x5B58;&#x5730;&#x5740;&#x3002; void * &#x8868;&#x793A;&#x672A;&#x786E;&#x5B9A;&#x7C7B;&#x578B;&#x7684;&#x6307;&#x9488;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-keyword">int</span> value = <span class="hljs-number">200</span>;
<span class="hljs-keyword">int</span>* ip;      <span class="hljs-comment">//  ip&#x662F;&#x4E00;&#x4E2A;&#x6307;&#x5411;int&#x7C7B;&#x578B;&#x7684;&#x6307;&#x9488;</span>
<span class="hljs-keyword">int</span> *ip <span class="hljs-comment">// &#x7ED3;&#x679C;&#x8DDF; int* ip &#x5B8C;&#x5168;&#x4E00;&#x6837;&#x3002;&#xFF08;&#x5EFA;&#x8BAE;&#x8FD9;&#x6837;&#x5199;&#xFF09;</span>

ip = &amp;value;<span class="hljs-comment">// &amp;&#x7B26;&#x53F7;&#x662F;&#x83B7;&#x5F97; value &#x8FD9;&#x4E2A;&#x53D8;&#x91CF;&#x7684;&#x5730;&#x5740;</span>
<span class="hljs-keyword">int</span> reslut = *ip;  <span class="hljs-comment">// *&#x662F;&#x83B7;&#x5F97;&#x6307;&#x9488;ip&#x6307;&#x5411;&#x7684;&#x53D8;&#x91CF;&#x7684;&#x503C;</span>

<span class="hljs-keyword">int</span>* intPtr;
<span class="hljs-keyword">int</span> value = <span class="hljs-number">10</span>;
intPtr  = &amp;value; <span class="hljs-comment">// &amp;value &#x83B7;&#x5F97;&#x6307;&#x5411;10&#x7684;&#x6307;&#x9488;</span>
*intPtr = <span class="hljs-number">200</span>;  <span class="hljs-comment">// &#x76F4;&#x63A5;&#x5C06;&#x6307;&#x9488;&#x6307;&#x5411;&#x7684;&#x90A3;&#x4E2A;&#x503C;&#x6539;&#x6210; 200</span>
</code></pre>
<h3 id="&#x4E8C;&#x7EA7;&#x6307;&#x9488;-&#x3001;&#x591A;&#x7EA7;&#x6307;&#x9488;"><a name="&#x4E8C;&#x7EA7;&#x6307;&#x9488;-&#x3001;&#x591A;&#x7EA7;&#x6307;&#x9488;" class="anchor-navigation-ex-anchor" href="#&#x4E8C;&#x7EA7;&#x6307;&#x9488;-&#x3001;&#x591A;&#x7EA7;&#x6307;&#x9488;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.1. &#x4E8C;&#x7EA7;&#x6307;&#x9488; &#x3001;&#x591A;&#x7EA7;&#x6307;&#x9488;</h3>
<pre><code class="lang-xml">int  **ptr2; //&#x4E8C;&#x7EA7;&#x6307;&#x9488;&#x3002; ptr2&#x6307;&#x5411;&#x4E00;&#x4E2A;&#x5730;&#x5740;&#xFF0C;&#x8FD9;&#x4E2A;&#x5730;&#x5740;&#x4E2D;&#x5B58;&#x653E;&#x7684;&#x53D8;&#x91CF;&#x662F;&#x4E00;&#x4E2A; int&#x6307;&#x9488;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x3002;
int  ***ptr3; // &#x4E09;&#x7EA7;&#x6307;&#x9488;
</code></pre>
<h3 id="&#x6570;&#x7EC4;&#x6307;&#x9488;"><a name="&#x6570;&#x7EC4;&#x6307;&#x9488;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;&#x6307;&#x9488;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.2. &#x6570;&#x7EC4;&#x6307;&#x9488;</h3>
<p>&#x6570;&#x7EC4;&#x6307;&#x9488; &#x6307;&#x5411;&#x6570;&#x7EC4;&#x7684;&#x9996;&#x5730;&#x5740;</p>
<pre><code class="lang-xml">int arr[] = {1 ,2,3,4};
int *ptr = arr; // &#x6307;&#x5411;&#x6570;&#x7EC4;&#x7684;&#x9996;&#x5730;&#x5740;&#x3002;&#x6570;&#x7EC4;&#x8DDF;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x4E0D;&#x4E00;&#x6837;&#x4E0D;&#x9700;&#x8981;&#x7528;&amp;&#x53D6;&#x5730;&#x5740;&#x3002;arr&#x53EF;&#x4EE5;&#x8BA4;&#x4E3A;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x6307;&#x9488;&#x4E86;&#x3002;
ptr++;
printf(&quot;%d\n&quot; , *ptr);

int arr2[] = { 8 ,9 ,10 };
int (*ptr2)[3] = &amp;arr2; // &#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x6307;&#x9488;&#x3002; &#x6570;&#x7EC4;&#x6307;&#x9488; &#x3002;
//int  *ptrArr[3];     //  &#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#x3002; &#x6307;&#x9488;&#x6570;&#x7EC4;&#x3002; 
printf(&quot;bbb= %d\n&quot;,   (*ptr2)[0]   ); // *ptr2 &#x83B7;&#x5F97;&#x6570;&#x7EC4;&#xFF0C;&#x4EE3;&#x8868;&#x6570;&#x7EC4;&#x7684;&#x9996;&#x5730;&#x5740;
int result =  * (*ptr2 +1 ) ; //&#x5BF9;&#x5730;&#x5740;&#x53D6;&#x503C; 
printf(&quot;ccc= %d\n&quot;, result); // 9
</code></pre>
<h3 id="&#x51FD;&#x6570;&#x6307;&#x9488;-&#x3001;-&#x65B9;&#x6CD5;&#x6307;&#x9488;"><a name="&#x51FD;&#x6570;&#x6307;&#x9488;-&#x3001;-&#x65B9;&#x6CD5;&#x6307;&#x9488;" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x6307;&#x9488;-&#x3001;-&#x65B9;&#x6CD5;&#x6307;&#x9488;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.3. &#x51FD;&#x6570;&#x6307;&#x9488; &#x3001; &#x65B9;&#x6CD5;&#x6307;&#x9488;</h3>
<p>&#x7CFB;&#x7EDF;&#x4E3A;&#x51FD;&#x6570;&#x4EE3;&#x7801;&#x5206;&#x914D;&#x4E00;&#x6BB5;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#xFF0C;&#x8FD9;&#x6BB5;&#x5B58;&#x50A8;&#x7A7A;&#x95F4;&#x7684;&#x9996;&#x5730;&#x5740;&#x79F0;&#x4E3A;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x7684;&#x5730;&#x5740;&#x3002;
&#x51FD;&#x6570;&#x540D;&#x8868;&#x793A;&#x7684;&#x5C31;&#x662F;&#x8FD9;&#x4E2A;&#x5730;&#x5740;&#x3002;&#x6307;&#x5411;&#x8FD9;&#x4E2A;&#x5730;&#x5740;&#x7684;&#x6307;&#x9488;&#x53EB;&#x505A;&#x51FD;&#x6570;&#x6307;&#x9488;&#x3002;<br>&#x51FD;&#x6570;&#x6307;&#x9488;&#x53EF;&#x4EE5;&#x50CF;&#x4E00;&#x822C;&#x51FD;&#x6570;&#x4E00;&#x6837;&#xFF0C;&#x7528;&#x4E8E;&#x8C03;&#x7528;&#x51FD;&#x6570;&#x3001;&#x4F20;&#x9012;&#x53C2;&#x6570;&#x3002;</p>
<pre><code class="lang-xml">// &#x5B9A;&#x4E49;
int sum(int x, int y)  
{
    return x+y;
}

int main(void)
{
  // &#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x503C;&#x7C7B;&#x578B; (* &#x6307;&#x9488;&#x53D8;&#x91CF;&#x540D;) (&#x51FD;&#x6570;&#x53C2;&#x6570;&#x7C7B;&#x578B;&#x5217;&#x8868;) 
  int (*ptrTest) (int, int);  //&#x5B9A;&#x4E49;&#x51FD;&#x6570;&#x6307;&#x9488;,&#x6307;&#x9488;&#x540D;&#x5B57;&#x53EF;&#x4EE5;&#x968F;&#x610F; 
  ptrTest = &amp;sum; // &#x5C06;&#x51FD;&#x6570;&#x7684;&#x5730;&#x5740;&#x7ED9;&#x6307;&#x9488; &#xFF0C;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x7406;&#x89E3;&#xFF0C;&#x51FD;&#x6570;&#x540D;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x6307;&#x9488;

  int a = 20, b = 10, c;
  c = ptrTest(a, b);  //&#x901A;&#x8FC7;&#x51FD;&#x6570;&#x6307;&#x9488;&#x8C03;&#x7528;&#x51FD;&#x6570;
  printf(&quot;a = %d\nb = %d\nmax = %d\n&quot;, a, b, c);
  getchar();
  return 0;
}
</code></pre>
<h2 id="&#x51FD;&#x6570;&#x56DE;&#x8C03;"><a name="&#x51FD;&#x6570;&#x56DE;&#x8C03;" class="anchor-navigation-ex-anchor" href="#&#x51FD;&#x6570;&#x56DE;&#x8C03;"><i class="fa fa-link" aria-hidden="true"></i></a>1.5. &#x51FD;&#x6570;&#x56DE;&#x8C03;</h2>
<pre><code class="lang-xml">int func3(int x ,int y)  
{
    return x + y;
}
// &#x7B2C;&#x4E09;&#x4E2A;&#x53C2;&#x6570;&#x5C31;&#x662F;&#x51FD;&#x6570;&#x6307;&#x9488;
int handle(int x, int y , int(*funcPtr)(int , int))
{
    return funcPtr(x , y);
}

void main(void)
{
    int x = 10, y = 20;
    int sum = handle(x, y, func3); // &#x51FD;&#x6570;&#x540D;&#x5176;&#x5B9E;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x6307;&#x9488;
    printf(&quot;sum= %d&quot; , sum);
}
</code></pre>
<h2 id="&#x6570;&#x7EC4;"><a name="&#x6570;&#x7EC4;" class="anchor-navigation-ex-anchor" href="#&#x6570;&#x7EC4;"><i class="fa fa-link" aria-hidden="true"></i></a>1.6. &#x6570;&#x7EC4;</h2>
<pre><code class="lang-xml">int arr[] = {1 ,2,3,4};

for ( int i : arr) {
  printf(&quot;%d  &quot; , i);
}

int sum = sizeof(arr) / sizeof(arr[0]);
for (int i = 0; i <span class="hljs-tag">&lt; <span class="hljs-attr">sum</span>; <span class="hljs-attr">i</span>++) {
  <span class="hljs-attr">printf</span>(&quot;%<span class="hljs-attr">d</span>  &quot;, <span class="hljs-attr">arr</span>[<span class="hljs-attr">i</span>]);
}
</span></code></pre>
<h2 id="&#x53D8;&#x91CF;"><a name="&#x53D8;&#x91CF;" class="anchor-navigation-ex-anchor" href="#&#x53D8;&#x91CF;"><i class="fa fa-link" aria-hidden="true"></i></a>1.7. &#x53D8;&#x91CF;</h2>
<p>&#x6CE8;&#x610F;c&#x8BED;&#x8A00;&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x548C;java&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#x3002;</p>
<pre><code class="lang-xml">Java&#x662F;&#x4E00;&#x79CD;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x8BED;&#x8A00;&#xFF0C;&#x5B83;&#x4E0D;&#x5141;&#x8BB8;&#x5728;&#x7C7B;&#x548C;&#x63A5;&#x53E3;&#x4E4B;&#x5916;&#x58F0;&#x660E;&#x51FD;&#x6570;&#x3002;
C&#x4E0D;&#x662F;&#x9762;&#x5411;&#x5BF9;&#x8C61;&#x7684;&#xFF0C;&#x6240;&#x4EE5;C&#x4E2D;&#x6240;&#x6709;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x548C;&#x51FD;&#x6570;&#x672C;&#x8D28;&#x4E0A;&#x5BF9;Java&#x800C;&#x8A00;&#x90FD;&#x662F;&#x9759;&#x6001;&#x7684;&#x3002;

&#x5728;C&#x4E2D;&#xFF0C;&#x5E38;&#x4F1A;&#x51FA;&#x73B0;&#x5728;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x4E2D;&#x5B9A;&#x4E49;&#x5927;&#x91CF;&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#xFF0C;
&#x5728;&#x5176;&#x4ED6;&#x6587;&#x4EF6;&#x4E2D;&#x901A;&#x8FC7;&#x5F15;&#x7528;&#x58F0;&#x660E;&#x8FD9;&#x4E9B;&#x53D8;&#x91CF;&#x6765;&#x5B9E;&#x73B0;&#x5171;&#x4EAB;&#xFF0C;&#x4F46;Java&#x4E0D;&#x5141;&#x8BB8;&#x6709;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x6216;&#x51FD;&#x6570;&#xFF1B;
</code></pre>
<h2 id="&#x5806;&#x6808;-&#x3001;&#x5185;&#x5B58;"><a name="&#x5806;&#x6808;-&#x3001;&#x5185;&#x5B58;" class="anchor-navigation-ex-anchor" href="#&#x5806;&#x6808;-&#x3001;&#x5185;&#x5B58;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8. &#x5806;&#x6808; &#x3001;&#x5185;&#x5B58;</h2>
<p>&#x6808;&#x7684;&#x5185;&#x5B58;&#x6700;&#x5927;&#x503C;&#x6BD4;&#x8F83;&#x5C0F;&#xFF0C;&#x5F00;&#x8F9F;&#x65B9;&#x5F0F;&#x7528;&#x9759;&#x6001;&#x5F00;&#x8F9F;&#x3002;&#x65B9;&#x6CD5;&#x7ED3;&#x675F;&#x540E;&#x4F1A;&#x81EA;&#x52A8;&#x56DE;&#x6536;&#x3002; &#x5806;&#x7684;&#x5185;&#x5B58;&#x6700;&#x5927;&#x503C;&#x8F83;&#x5927;&#xFF0C;&#x7528;&#x52A8;&#x6001;&#x65B9;&#x5F0F;&#x5F00;&#x8F9F;&#x3002;&#x4E0D;&#x4F1A;&#x81EA;&#x52A8;&#x56DE;&#x6536;&#xFF0C;&#x5FC5;&#x987B;&#x901A;&#x8FC7;&#x624B;&#x52A8;&#x91CA;&#x653E;&#x624D;&#x80FD;&#x88AB;&#x56DE;&#x6536;&#x3002;</p>
<h3 id="&#x9759;&#x6001;&#x5185;&#x5B58;"><a name="&#x9759;&#x6001;&#x5185;&#x5B58;" class="anchor-navigation-ex-anchor" href="#&#x9759;&#x6001;&#x5185;&#x5B58;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.1. &#x9759;&#x6001;&#x5185;&#x5B58;</h3>
<pre><code class="lang-xml">int arr[2*1024] ;// &#x9759;&#x6001;&#x5F00;&#x8F9F; 2K&#x5185;&#x5B58;
</code></pre>
<h3 id="&#x52A8;&#x6001;&#x5185;&#x5B58;"><a name="&#x52A8;&#x6001;&#x5185;&#x5B58;" class="anchor-navigation-ex-anchor" href="#&#x52A8;&#x6001;&#x5185;&#x5B58;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.2. &#x52A8;&#x6001;&#x5185;&#x5B58;</h3>
<pre><code class="lang-c"><span class="hljs-meta">#<span class="hljs-meta-keyword">include</span><span class="hljs-meta-string">&lt;malloc.h&gt;</span> &#x6216;&#x8005;  <span class="hljs-meta-string">&lt;stdlib.h&gt;</span> </span>
<span class="hljs-comment">//&#x82E5;&#x6210;&#x529F;&#x5C31;&#x8FD4;&#x56DE;&#x6307;&#x5411;&#x88AB;&#x5206;&#x914D;&#x5185;&#x5B58;&#x7A7A;&#x95F4;&#x7684;&#x6307;&#x9488;&#xFF0C;&#x5426;&#x5219;&#x5C31;&#x8FD4;&#x56DE;NULL</span>
<span class="hljs-keyword">int</span> *p = (<span class="hljs-keyword">int</span> *)  <span class="hljs-built_in">malloc</span>(<span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">int</span>) * <span class="hljs-number">10</span>); 

<span class="hljs-keyword">if</span> (p == <span class="hljs-literal">NULL</span>)
{
  <span class="hljs-keyword">return</span> ; 
}

<span class="hljs-built_in">memset</span>(p, <span class="hljs-number">0</span>, <span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">int</span>) * <span class="hljs-number">10</span>); <span class="hljs-comment">//&#x521D;&#x59CB;&#x5316;&#x7A7A;&#x95F4;</span>
<span class="hljs-comment">// &#x521D;&#x59CB;&#x5316;&#x6210;&#x529F;&#x540E;&#x9ED8;&#x8BA4;&#x521D;&#x59CB;&#x5316;&#x4E3A;0&#xFF0C;&#x65E0;&#x9700;&#x624B;&#x52A8;&#x521D;&#x59CB;&#x5316;</span>
<span class="hljs-keyword">int</span>* reslut = (<span class="hljs-keyword">int</span>*) <span class="hljs-built_in">calloc</span>(<span class="hljs-number">10</span> , <span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">int</span>));
<span class="hljs-comment">// &#x5BF9;&#x7533;&#x8BF7;&#x7684;&#x5185;&#x5B58;&#x8FDB;&#x884C;&#x5927;&#x5C0F;&#x7684;&#x8C03;&#x6574;</span>
p = (<span class="hljs-keyword">int</span>*)<span class="hljs-built_in">realloc</span>(p, <span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">int</span>) * <span class="hljs-number">10</span>); <span class="hljs-comment">// &#x5C06;&#x5927;&#x5C0F;&#x8C03;&#x6574;&#x4E3A;10</span>
<span class="hljs-built_in">free</span>(p);<span class="hljs-comment">// &#x624B;&#x52A8;&#x91CA;&#x653E;&#x5185;&#x5B58;</span>
</code></pre>
<h3 id="&#x5185;&#x5B58;&#x56DB;&#x533A;&#x6A21;&#x578B;"><a name="&#x5185;&#x5B58;&#x56DB;&#x533A;&#x6A21;&#x578B;" class="anchor-navigation-ex-anchor" href="#&#x5185;&#x5B58;&#x56DB;&#x533A;&#x6A21;&#x578B;"><i class="fa fa-link" aria-hidden="true"></i></a>1.8.3. &#x5185;&#x5B58;&#x56DB;&#x533A;&#x6A21;&#x578B;</h3>
<pre><code class="lang-xml">&#x4E00;&#x4E2A;&#x7531;c/C++&#x7F16;&#x8BD1;&#x7684;&#x7A0B;&#x5E8F;&#x5360;&#x7528;&#x7684;&#x5185;&#x5B58;&#x5206;&#x4E3A;&#x4EE5;&#x4E0B;&#x51E0;&#x4E2A;&#x90E8;&#x5206;
1&#x3001;&#x6808;&#x533A;&#xFF1A;&#x7531;&#x7F16;&#x8BD1;&#x5668;&#x81EA;&#x52A8;&#x5206;&#x914D;&#x91CA;&#x653E; &#xFF0C;&#x5B58;&#x653E;&#x51FD;&#x6570;&#x7684;&#x53C2;&#x6570;&#x503C;&#xFF0C;&#x5C40;&#x90E8;&#x53D8;&#x91CF;&#x7684;&#x503C;&#x7B49;&#x3002;
2&#x3001;&#x5806;&#x533A;&#xFF1A;&#x7531;&#x7A0B;&#x5E8F;&#x5458;&#x5206;&#x914D;&#x91CA;&#x653E;&#xFF0C; &#x82E5;&#x7A0B;&#x5E8F;&#x5458;&#x4E0D;&#x91CA;&#x653E;&#xFF0C;&#x7A0B;&#x5E8F;&#x7ED3;&#x675F;&#x65F6;&#x53EF;&#x80FD;&#x7531;&#x7CFB;&#x7EDF;&#x56DE;&#x6536; &#x3002;
3&#x3001;&#x6570;&#x636E;&#x533A;&#xFF1A;&#x4E3B;&#x8981;&#x5305;&#x62EC;&#x9759;&#x6001;&#x5168;&#x5C40;&#x533A;&#x548C;&#x5E38;&#x91CF;&#x533A;&#x3002;
   &#x521D;&#x59CB;&#x5316;&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x548C;&#x9759;&#x6001;&#x53D8;&#x91CF;&#x5728;&#x4E00;&#x5757;&#x533A;&#x57DF;&#xFF0C; 
   &#x672A;&#x521D;&#x59CB;&#x5316;&#x7684;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x548C;&#x672A;&#x521D;&#x59CB;&#x5316;&#x7684;&#x9759;&#x6001;&#x53D8;&#x91CF;&#x5728;&#x76F8;&#x90BB;&#x7684;&#x53E6;&#x4E00;&#x5757;&#x533A;&#x57DF;&#x3002; 
   &#x7A0B;&#x5E8F;&#x7ED3;&#x675F;&#x540E;&#x7531;&#x7CFB;&#x7EDF;&#x91CA;&#x653E;
4&#x3001;&#x4EE3;&#x7801;&#x533A;&#xFF1A;&#x5B58;&#x653E;&#x51FD;&#x6570;&#x4F53;&#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x4EE3;&#x7801;&#x3002;
</code></pre>
<p><br></p>
<h2 id="&#x7ED3;&#x6784;&#x4F53;"><a name="&#x7ED3;&#x6784;&#x4F53;" class="anchor-navigation-ex-anchor" href="#&#x7ED3;&#x6784;&#x4F53;"><i class="fa fa-link" aria-hidden="true"></i></a>1.9. &#x7ED3;&#x6784;&#x4F53;</h2>
<p>c&#x7684;&#x7ED3;&#x6784;&#x4F53;&#x4E0E;c++&#x7684;&#x7C7B;&#x4F3C;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x5982;c++&#x7684;&#x7ED3;&#x6784;&#x4F53;&#x5F3A;&#x5927;&#x3002;</p>
<pre><code class="lang-c"><span class="hljs-comment">// &#x666E;&#x901A;&#x65B9;&#x5F0F;</span>
<span class="hljs-keyword">struct</span> student {
  <span class="hljs-keyword">char</span> name[<span class="hljs-number">20</span>];     
  <span class="hljs-keyword">int</span> age;          
} stu1, stu2;
<span class="hljs-keyword">struct</span> student stu3;
stu3.age = <span class="hljs-number">20</span>;
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x5E74;&#x7EAA;=%d\n&quot;</span> ,stu3.age);

<span class="hljs-comment">//&#x5E26;&#x522B;&#x540D;&#x65B9;&#x5F0F;,STUDENT&#x662F;&#x522B;&#x540D;</span>
<span class="hljs-keyword">typedef</span> <span class="hljs-keyword">struct</span> student {
  <span class="hljs-keyword">char</span> name[<span class="hljs-number">20</span>];
  <span class="hljs-keyword">int</span> age;
}STUDENT ;
<span class="hljs-comment">// &#x522B;&#x540D;&#x65B9;&#x5F0F; &#x53EF;&#x4EE5;&#x7701;&#x7565; struct</span>
STUDENT stu3;
</code></pre>
<pre><code class="lang-c"><span class="hljs-comment">// &#x7A7A;&#x7ED3;&#x6784;&#x4F53;</span>
<span class="hljs-keyword">struct</span> URLProtocol11111111111 ;
&#x6216;
<span class="hljs-keyword">struct</span> URLProtocol11111111111
</code></pre>
<p><br></p>
<h2 id="&#x8054;&#x5408;&#x4F53;-&#x5171;&#x7528;&#x4F53;"><a name="&#x8054;&#x5408;&#x4F53;-&#x5171;&#x7528;&#x4F53;" class="anchor-navigation-ex-anchor" href="#&#x8054;&#x5408;&#x4F53;-&#x5171;&#x7528;&#x4F53;"><i class="fa fa-link" aria-hidden="true"></i></a>1.10. &#x8054;&#x5408;&#x4F53; &#x5171;&#x7528;&#x4F53;</h2>
<pre><code class="lang-c">&#x6240;&#x6709;&#x6210;&#x5458;&#x53D8;&#x91CF;&#x5171;&#x4EAB;&#x4E00;&#x4E2A;&#x5185;&#x5B58;,
&#x5BF9;&#x4E8E;Union&#x7684;&#x4E0D;&#x540C;&#x6210;&#x5458;&#x8D4B;&#x503C;&#xFF0C;&#x5C06;&#x4F1A;&#x5BF9;&#x5176;&#x4ED6;&#x6210;&#x5458;&#x91CD;&#x5199;&#xFF0C;&#x539F;&#x6765;&#x6210;&#x5458;&#x7684;&#x503C;&#x5C31;&#x4E0D;&#x5B58;&#x5728;&#x4E86;&#x3002;
&#x5176;&#x4ED6;&#x7684;&#x7528;&#x6CD5;&#x53C2;&#x8003;<span class="hljs-keyword">struct</span> &#x3002;

<span class="hljs-keyword">union</span>  Data {
  <span class="hljs-keyword">char</span> name[<span class="hljs-number">20</span>];     
  <span class="hljs-keyword">int</span> age;          
} data1,  data2 ;
</code></pre>
<p><br></p>
<h2 id="&#x63A7;&#x5236;&#x53F0;-&#x8F93;&#x5165;-&#x8F93;&#x51FA;"><a name="&#x63A7;&#x5236;&#x53F0;-&#x8F93;&#x5165;-&#x8F93;&#x51FA;" class="anchor-navigation-ex-anchor" href="#&#x63A7;&#x5236;&#x53F0;-&#x8F93;&#x5165;-&#x8F93;&#x51FA;"><i class="fa fa-link" aria-hidden="true"></i></a>1.11. &#x63A7;&#x5236;&#x53F0; &#x8F93;&#x5165; &#x8F93;&#x51FA;</h2>
<pre><code class="lang-c"><span class="hljs-built_in">printf</span>(...) <span class="hljs-comment">// &#x5C06;&#x6307;&#x5B9A;&#x7684;&#x5185;&#x5BB9;&#x8F93;&#x51FA;&#x5230;&#x63A7;&#x5236;&#x53F0;</span>
<span class="hljs-built_in">scanf</span>(...) <span class="hljs-comment">// &#x63A5;&#x6536;&#x952E;&#x76D8;&#x8F93;&#x5165;&#x7684;&#x5185;&#x5BB9;,&#x53EA;&#x6709;&#x6309;&#x4E0B;&#x56DE;&#x8F66;&#x952E;scanf&#x624D;&#x4F1A;&#x4ECE;&#x7F13;&#x51B2;&#x533A;&#x53D6;&#x8D70;&#x6570;&#x636E;</span>

<span class="hljs-keyword">int</span> a ;
<span class="hljs-built_in">scanf</span>(<span class="hljs-string">&quot;%d&quot;</span>, &amp;a );
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x8F93;&#x5165;int&#x662F;= %d\n&quot;</span>, a );

<span class="hljs-keyword">char</span> str[<span class="hljs-number">50</span>] ;
<span class="hljs-built_in">scanf</span>(<span class="hljs-string">&quot;%s&quot;</span>, str );
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x8F93;&#x5165;&#x5B57;&#x7B26;&#x4E32;&#x662F;= %s\n&quot;</span>, str );

<span class="hljs-keyword">char</span> c ;
c = getchar();<span class="hljs-comment">// &#x83B7;&#x5F97;&#x6309;&#x56DE;&#x8F66;&#x7B26;&#x540E;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x3002;&#x63A7;&#x5236;&#x53F0;&#x7A0B;&#x5E8F;&#x6D4B;&#x8BD5;&#x5E38;&#x7528;&#x6765;&#x6682;&#x505C;&#x5C4F;&#x5E55;</span>
<span class="hljs-built_in">putchar</span>(c);<span class="hljs-comment">// &#x8F93;&#x51FA;&#x4E00;&#x4E2A;&#x5B57;&#x7B26;&#x5230; &#x63A7;&#x5236;&#x53F0;</span>

<span class="hljs-comment">// &#x4E00;&#x4E2A;&#x6C49;&#x5B57;&#x5360;&#x7528;&#x4E24;&#x4E2A;&#x5B57;&#x8282;</span>
<span class="hljs-keyword">char</span> c1, c2;
c1 = getchar();
c2 = getchar();
<span class="hljs-built_in">putchar</span>(c1);
<span class="hljs-built_in">putchar</span>(c2);
---------------------------------------------
<span class="hljs-keyword">char</span> c1, c2;
<span class="hljs-comment">//#include &lt;conio.h&gt;</span>
<span class="hljs-comment">// &#x8F93;&#x5165;&#x5B8C;&#x6BD5;&#x5373;&#x88AB;&#x8BFB;&#x53D6;&#xFF0C;&#x65E0;&#x9700;&#x6309;&#x56DE;&#x8F66;&#x952E; . &#x5C4F;&#x5E55;&#x4E0A;&#x4F1A;&#x663E;&#x793A;&#x8F93;&#x5165;&#x7684;&#x5185;&#x5BB9;</span>
c1 = getche();
<span class="hljs-comment">// &#x8F93;&#x5165;&#x5B8C;&#x6BD5;&#x5373;&#x88AB;&#x8BFB;&#x53D6;&#xFF0C;&#x65E0;&#x9700;&#x6309;&#x56DE;&#x8F66;&#x952E; &#x3002;&#x5C4F;&#x5E55;&#x4E0A;&#x4E0D;&#x4F1A;&#x663E;&#x793A;&#x8F93;&#x5165;&#x7684;&#x5185;&#x5BB9;</span>
c2 = getch();
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;\nThe character getche()= %c \n&quot;</span>, c1);
<span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;The character getch() = %c \n&quot;</span>, c2);
---------------------------------------------
<span class="hljs-keyword">char</span> s[<span class="hljs-number">50</span>];
<span class="hljs-comment">// &#x8F93;&#x5165;&#x5B57;&#x7B26;&#x4E32; &#xFF08;&#x53EF;&#x4EE5;&#x6709;&#x7A7A;&#x683C;&#xFF09;</span>
gets_s(s);
<span class="hljs-comment">// &#x8F93;&#x51FA;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-built_in">puts</span>(s);
---------------------------------------------
<span class="hljs-keyword">char</span> c1;
c1 =getc(<span class="hljs-built_in">stdin</span>);
putc(c1 ,<span class="hljs-built_in">stdout</span>);
</code></pre>
<p><br></p>
<h2 id="&#x5E38;&#x7528;&#x51FD;&#x6570;"><a name="&#x5E38;&#x7528;&#x51FD;&#x6570;" class="anchor-navigation-ex-anchor" href="#&#x5E38;&#x7528;&#x51FD;&#x6570;"><i class="fa fa-link" aria-hidden="true"></i></a>1.12. &#x5E38;&#x7528;&#x51FD;&#x6570;</h2>
<h3 id="memcpy"><a name="memcpy" class="anchor-navigation-ex-anchor" href="#memcpy"><i class="fa fa-link" aria-hidden="true"></i></a>1.12.1. memcpy(...)</h3>
<pre><code class="lang-c"><span class="hljs-comment">// &#x5185;&#x5B58;&#x62F7;&#x8D1D;</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> *<span class="hljs-title">memcpy</span><span class="hljs-params">(<span class="hljs-keyword">void</span> *dest, <span class="hljs-keyword">const</span> <span class="hljs-keyword">void</span> *src, size_t n)</span>
</span></code></pre>
<h3 id="memset"><a name="memset" class="anchor-navigation-ex-anchor" href="#memset"><i class="fa fa-link" aria-hidden="true"></i></a>1.12.2. memset(...)</h3>
<pre><code class="lang-c"><span class="hljs-comment">// &#x5185;&#x5B58;&#x91CD;&#x7F6E;</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> *<span class="hljs-title">memset</span><span class="hljs-params">(<span class="hljs-keyword">void</span> *s, <span class="hljs-keyword">int</span> ch, size_t n)</span></span>;
&#x5C06;s&#x4E2D;&#x5F53;&#x524D;&#x4F4D;&#x7F6E;&#x540E;&#x9762;&#x7684;n&#x4E2A;&#x5B57;&#x8282; &#x7528; ch &#x66FF;&#x6362;&#x5E76;&#x8FD4;&#x56DE; s
</code></pre>
<h2 id="&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><a name="&#x6587;&#x4EF6;&#x64CD;&#x4F5C;" class="anchor-navigation-ex-anchor" href="#&#x6587;&#x4EF6;&#x64CD;&#x4F5C;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13. &#x6587;&#x4EF6;&#x64CD;&#x4F5C;</h2>
<h3 id="&#x8BFB;&#x5199;&#x6743;&#x9650;"><a name="&#x8BFB;&#x5199;&#x6743;&#x9650;" class="anchor-navigation-ex-anchor" href="#&#x8BFB;&#x5199;&#x6743;&#x9650;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13.1. &#x8BFB;&#x5199;&#x6743;&#x9650;</h3>
<table>
<thead>
<tr>
<th><a href="http://www.cnblogs.com/kangjianwei101/p/5220021.html" target="_blank">&#x64CD;&#x4F5C;&#x7C7B;&#x578B;</a></th>
<th>&#x7279;&#x70B9;</th>
<th>&#x6587;&#x4EF6;&#x4E0D;&#x5B58;&#x5728;&#x65F6;</th>
<th>&#x7279;&#x70B9;</th>
</tr>
</thead>
<tbody>
<tr>
<td>r</td>
<td>&#x53EA;&#x8BFB;</td>
<td>&#x62A5;&#x9519;</td>
<td>&#x8BFB; &#x4EFB;&#x610F;&#x4F4D;&#x7F6E;</td>
</tr>
<tr>
<td>w</td>
<td>&#x53EA;&#x5199;</td>
<td>&#x65B0;&#x5EFA;</td>
<td>&#x6E05;&#x7A7A;&#x539F;&#x6587;&#x4EF6;&#xFF0C;&#x5199;&#x5165;&#x4EFB;&#x610F;&#x4F4D;&#x7F6E;</td>
</tr>
<tr>
<td>a</td>
<td>&#x53EA;&#x5199;</td>
<td>&#x65B0;&#x5EFA;</td>
<td>&#x4E0D;&#x6E05;&#x7A7A; &#xFF0C;&#x53EA;&#x80FD;&#x5728;&#x5C3E;&#x90E8;&#x5199;</td>
</tr>
<tr>
<td>r+</td>
<td>&#x8BFB;&#x5199;</td>
<td>&#x62A5;&#x9519;</td>
<td>&#x4E0D;&#x6E05;&#x7A7A;&#xFF0C; &#x4EFB;&#x610F;&#x4F4D;&#x7F6E;&#x8BFB;&#x5199;</td>
</tr>
<tr>
<td>w+</td>
<td>&#x8BFB;&#x5199;</td>
<td>&#x65B0;&#x5EFA;</td>
<td>&#x6E05;&#x7A7A;&#xFF0C;&#x4EFB;&#x610F;&#x4F4D;&#x7F6E;&#x8BFB;&#x5199;</td>
</tr>
<tr>
<td>a+</td>
<td>&#x8BFB;&#x5199;</td>
<td>&#x65B0;&#x5EFA;</td>
<td>&#x4E0D;&#x6E05;&#x7A7A; &#xFF0C; &#x4EFB;&#x610F;&#x4F4D;&#x7F6E;&#x8BFB; &#xFF0C; &#x5C3E;&#x90E8;&#x5199;</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>&#x6253;&#x5F00;&#x6A21;&#x5F0F;</th>
<th>&#x53EA;&#x8BFB;</th>
<th>&#x53EA;&#x5199;</th>
<th>&#x8BFB;&#x5199;</th>
<th>&#x8BFB;&#x5199;</th>
<th>&#x8BFB;&#x5199;</th>
<th>&#x8BFB;&#x5199;</th>
</tr>
</thead>
<tbody>
<tr>
<td>&#x6587;&#x672C;&#x6A21;&#x5F0F;</td>
<td>r</td>
<td>w</td>
<td>a</td>
<td>r+</td>
<td>w+</td>
<td>a+</td>
</tr>
<tr>
<td>&#x4E8C;&#x8FDB;&#x5236;&#x6A21;&#x5F0F;</td>
<td>rb</td>
<td>wb</td>
<td>ab</td>
<td>rb+ ,  r+b</td>
<td>wb+ , w+b</td>
<td>ab+  , a+b</td>
</tr>
</tbody>
</table>
<h3 id="&#x8BFB;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;"><a name="&#x8BFB;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;" class="anchor-navigation-ex-anchor" href="#&#x8BFB;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13.2. &#x8BFB;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;</h3>
<pre><code class="lang-c"><span class="hljs-comment">// &#x6B64;&#x7A0B;&#x5E8F;&#x8BFB;&#x53D6;ANSI&#x7F16;&#x7801;&#x683C;&#x5F0F;&#x6B63;&#x5E38;&#xFF0C;&#x5176;&#x4ED6;&#x683C;&#x5F0F;&#x4E2D;&#x6587;&#x4E71;&#x7801;</span>
FILE * fp;
<span class="hljs-keyword">if</span> ((fp = fopen(<span class="hljs-string">&quot;D:\\data1.txt&quot;</span>, <span class="hljs-string">&quot;r+&quot;</span>)) == <span class="hljs-literal">NULL</span>)
{
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;can not open the file\n&quot;</span>);
  <span class="hljs-built_in">exit</span>(<span class="hljs-number">0</span>);
}

<span class="hljs-keyword">char</span> ch = fgetc(fp);
<span class="hljs-keyword">while</span> (ch != EOF)
{
  <span class="hljs-built_in">putchar</span>(ch);
  ch = fgetc(fp);
}
fclose(fp);
</code></pre>
<p><br></p>
<h3 id="&#x5199;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;"><a name="&#x5199;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;" class="anchor-navigation-ex-anchor" href="#&#x5199;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13.3. &#x5199;&#x6587;&#x672C;&#xFF08;&#x6709;&#x4E2D;&#x6587;&#xFF09;</h3>
<pre><code class="lang-c"><span class="hljs-comment">//&#x6B64;&#x7A0B;&#x5E8F;&#x4FDD;&#x5B58;&#x7684;&#x7F16;&#x7801;&#x683C;&#x5F0F;&#x662F;ANSI</span>
FILE * fp;
<span class="hljs-keyword">if</span> ((fp = fopen(<span class="hljs-string">&quot;D:\\data1.txt&quot;</span>, <span class="hljs-string">&quot;w+&quot;</span>)) == <span class="hljs-literal">NULL</span>)
{
  <span class="hljs-built_in">printf</span>(<span class="hljs-string">&quot;&#x6587;&#x4EF6;&#x6253;&#x5F00;&#x5931;&#x8D25;\n&quot;</span>);
}
<span class="hljs-keyword">else</span> {
  <span class="hljs-keyword">char</span> str[] = <span class="hljs-string">&quot;123 a b &#x4E2D;&#x6587;&#x6D4B;&#x8BD5; 123 abc abcdefg&quot;</span>;
  <span class="hljs-keyword">int</span> len = <span class="hljs-built_in">strlen</span>(str);
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; len; i++)
  {
    fputc(str[i], fp);
  }
}
fclose(fp);
</code></pre>
<p><br></p>
<h3 id="&#x590D;&#x5236;&#x6587;&#x4EF6;-&#xFF0C;&#x4E8C;&#x8FDB;&#x5236;&#xFF08;&#x56FE;&#x7247;&#xFF0C;&#x97F3;&#x9891;&#xFF09;"><a name="&#x590D;&#x5236;&#x6587;&#x4EF6;-&#xFF0C;&#x4E8C;&#x8FDB;&#x5236;&#xFF08;&#x56FE;&#x7247;&#xFF0C;&#x97F3;&#x9891;&#xFF09;" class="anchor-navigation-ex-anchor" href="#&#x590D;&#x5236;&#x6587;&#x4EF6;-&#xFF0C;&#x4E8C;&#x8FDB;&#x5236;&#xFF08;&#x56FE;&#x7247;&#xFF0C;&#x97F3;&#x9891;&#xFF09;"><i class="fa fa-link" aria-hidden="true"></i></a>1.13.4. &#x590D;&#x5236;&#x6587;&#x4EF6; &#xFF0C;&#x4E8C;&#x8FDB;&#x5236;&#xFF08;&#x56FE;&#x7247;&#xFF0C;&#x97F3;&#x9891;&#xFF09;</h3>
<pre><code class="lang-c"><span class="hljs-keyword">char</span> *read_path = <span class="hljs-string">&quot;D:\\music1.mp3&quot;</span>;
<span class="hljs-keyword">char</span> *write_path = <span class="hljs-string">&quot;D:\\music2.mp3&quot;</span>;

FILE *read_fp = fopen(read_path, <span class="hljs-string">&quot;rb&quot;</span>);
FILE *write_fp = fopen(write_path, <span class="hljs-string">&quot;wb&quot;</span>);

<span class="hljs-comment">//&#x7F13;&#x51B2;&#x533A;&#x57DF;</span>
<span class="hljs-keyword">int</span> buff[<span class="hljs-number">50</span>];
<span class="hljs-comment">//&#x6BCF;&#x6B21;&#x8BFB;&#x5230;&#x7684;&#x6570;&#x636E;&#x957F;&#x5EA6;</span>
<span class="hljs-keyword">int</span> len = <span class="hljs-number">0</span>;
<span class="hljs-keyword">while</span> ( (len = fread(buff, <span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">int</span>), <span class="hljs-number">50</span>, read_fp)) != <span class="hljs-number">0</span>)
{
  <span class="hljs-comment">//&#x5C06;&#x8BFB;&#x5230;&#x7684;&#x5185;&#x5BB9;&#x5199;&#x5165;&#x65B0;&#x7684;&#x6587;&#x4EF6;</span>
  fwrite(buff, <span class="hljs-keyword">sizeof</span>(<span class="hljs-keyword">int</span>), len, write_fp);
}
fclose(read_fp);
fclose(write_fp);
</code></pre>
<footer class="page-footer"><span class="copyright">&#x65E0;&#x7248;&#x6743; &#x53EF;&#x4EE5;&#x65E0;&#x9650;&#x5236;&#x4F7F;&#x7528;&#xFF01; all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x65F6;&#x95F4;&#xFF1A;
2019-12-23 20:03:30
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../linux/android底层开发.html" class="navigation navigation-prev " aria-label="Previous page: android底层开发">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="c基础.html" class="navigation navigation-next " aria-label="Next page: c基础">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"c","level":"1.3","depth":1,"next":{"title":"c基础","level":"1.3.1","depth":2,"path":"chinese/c语言/c基础.md","ref":"chinese/c语言/c基础.md","articles":[]},"previous":{"title":"android底层开发","level":"1.2.2","depth":2,"path":"chinese/linux/android底层开发.md","ref":"chinese/linux/android底层开发.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","versions-select","fontsettings","sharing","tbfed-pagefooter","donate","local-video","splitter","edit-link","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"无版权 可以无限制使用！","modify_label":"该文件更新时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"versions-select":{"type":"branches"},"donate":{"alipay":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_支付宝收款码.png","alipayText":"支付宝打赏","button":"打赏","title":"","wechat":"https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803011956_osChina_微信收款码.png","wechatText":"微信打赏"},"fontsettings":{"family":"sans","size":2,"theme":"sepia"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"versions":{"options":[{"value":"https://www.aivin666.cn/java_android/","text":"v1.0"}]},"sharing":{"all":["facebook","google","twitter","weibo","instapaper"],"facebook":false,"google":true,"instapaper":false,"twitter":false,"vk":false,"weibo":true},"edit-link":{"label":"托管页面","base":"https://www.baidu.com/"},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/c语言/c基础.md","mtime":"2019-12-23T12:03:30.425Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-12-24T10:38:14.517Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-versions-select/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-edit-link/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

